﻿using System;
using System.Collections;
using System.Text.RegularExpressions;

namespace MISTBowl_Brackets
{
	public static class HumanReadableRoundNames
	{
		static readonly Hashtable m_hashtable = new Hashtable(0);

		public static string GetHumanReadableName(string roundName)
		{
			try
			{
				if (m_hashtable.Count == 0)
				{
					m_hashtable.Add("QF", "QUARTER-FINALS");
					m_hashtable.Add("SF", "SEMI-FINALS");
					m_hashtable.Add("F", "FINALS");
				}
				if (Regex.IsMatch(roundName, "^PRELIM[0-9]+/[0-9]+$"))
					return "PRELIMINARY ROUND " + Regex.Split(roundName, "^PRELIM")[1].Split('/')[0] + " OF " + roundName.Split('/')[1];
				if (Regex.IsMatch(roundName, "^ROUNDOF[0-9]+$"))
					return "ROUND OF " + Regex.Split(roundName, "^ROUNDOF")[1];
				if (m_hashtable[roundName] == null)
					throw new ApplicationException();
				return (string)m_hashtable[roundName];
			}
			catch (Exception e)
			{
				Traceback.Write("At string GetHumanReadableName(string) (class HumanReadableRoundNames):");
				throw e;
			}
		}
	}
}